<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>新增收货地址</title>
		<link rel="stylesheet" href="layui/css/layui.css" />
		<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="layer/layer.js"></script>
		<script type="text/javascript" src="layui/layui.js" ></script>
	</head>

	<body>

		<form class="layui-form" action="" style="width: 650px;margin-top: 20px;">
			<div class="layui-form-item">
				<label class="layui-form-label">收件人</label>
				<div class="layui-input-block">
					<input id="userName" type="text" name="name" required lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">电话</label>
				<div class="layui-input-block">
					<input type="phone" name="phone" required lay-verify="required" placeholder="请输入电话" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">地区</label>
				<div class="layui-input-block">
					<select name="city" lay-verify="required">
						<option value=""></option>
						<option value="0">北京</option>
						<option value="1">上海</option>
						<option value="2">广州</option>
						<option value="3">深圳</option>
						<option value="4">杭州</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">详细地址</label>
				<div class="layui-input-block">
					<textarea name="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">添加</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>

		<script>
			//Demo
			layui.use('form', function() {
				var form = layui.form;
				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
				//监听提交
				form.on('submit(formDemo)', function(data) {
					var val = $("#userName").val();
					parent.layer.msg('收件人 ' +val + ' 添加成功！');
					parent.layer.close(index);
				});
			});
		</script>

	</body>

</html>